package com.boge.util;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.context.ApplicationEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;

/**
 * 将sysout和syserr输出到日志
 * @author Administrator
 *
 */
public class StdOutListener implements ApplicationListener {

	@Override
	public void onApplicationEvent(ApplicationEvent arg0) {
		Log logger = LogFactory.getLog(this.getClass().getName().getClass());
		StdOutErrRedirect.redirectSystemOutAndErrToLog(logger);
		
		String ssmPath = getClass().getResource("/").getFile().toString();
		System.setProperty("ssmPath", "D:/ssm");
	}  
	
    /*@Override  
    public void contextDestroyed(ServletContextEvent arg0) {  
  
    }  
  
    @Override  
    public void contextInitialized(ServletContextEvent arg0) {  
        StdOutErrRedirect.redirectSystemOutAndErrToLog();  
    }*/

	/*@Override
	public void onApplicationEvent(ContextRefreshedEvent arg0) {
		System.out.println("加载");
		StdOutErrRedirect.redirectSystemOutAndErrToLog();
	}  */
  
}
